<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('审批管理')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>人员姓名：</p>
                                <input type="text" name="keyword"/>
                            </li>
                            <li>
                                <p>身份证：</p>
                                <input type="text" name="keyword"/>
                            </li>
                            <li>
							项目类型：<select name="projectType" th:with="type=${@dict.getType('sys_normal_disable')}">
							            <option value="">全部</option>
										<option value="房建">房建</option>
										<option value="市政">市政</option>
								   </select>
							</li>
							<li class="select-time">
                                <p>建档时间：</p>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginReportTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endReportTime"/>
                            </li> 
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>
            <div class="col-sm-12 select-table table-striped">
                 <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:src="@{/js/plugins/datetime/moment.js}"></script>
    <script th:inline="javascript">
    var prefix = ctx + "monitor";
    var proPrefix = ctx + "projectArchives/projectArchives";
    var enterPriseprefix = ctx + "enterprise/enterprise";
    
    $(function() {
    	 var options = {
    			url: prefix + "/list",
                updateUrl: prefix + "/edit/{id}",
                exportUrl: prefix + "/export",
                detailUrl: prefix + "/detail/{id}",
                detailFourUrl: proPrefix + "/detail/{id}",
                detailOneUrl: enterPriseprefix + "/bulidUnitDetail/{id}",
                detailTwoUrl: enterPriseprefix + "/detail/{id}",
                modalName: "审批管理",
                columns: [{
                        field: 'id',
                        title: '序号',
						formatter: function (value, row, index) {
						
						    return index + 1;
						}
                    },
                    {
                        field: 'proGuid',
                        title: '项目标识',
						visible: false
	                },
                    {
                        field: 'cpGuid',
                        title: '施工许可标识符',
						visible: false
	                }, 
					{
                        field: 'unitEngineeringName',
                        title: '人员姓名'
                    },
                    {
                        field: 'projectName',
                        title: '监督项目',
						formatter: function (value, row, index) {
							var actions = [];
							if(!$.common.isEmpty(row.proGuid) && !$.common.isEmpty(value)){
								actions.push('<a href="javascript:void(0)" onclick="$.operate.detailTabRewriteFour(\'' + value + '\',\''+ row.proGuid +'\')">'+value+'</a> ');
							}
							return actions.join('');
						}
                    },
					{
                        field: 'buildName',
                        title: '建设单位(新数据)',
						visible: false
	                },
					{
                        field: 'buildGuid',
                        title: '建设单位标识符(新数据)',
						visible: false
	                },
					{
                        field: 'constructUnitId',
                        title: '建设单位标识符(老数据)',
						visible: false
	                },
                    {
                        field: 'constructUnit',
                        title: '建设单位',
						formatter: function (value, row, index) {
							var actions = [];
							var name = '';
							var guid = '';
							if(!$.common.isEmpty(row.buildGuid) && !$.common.isEmpty(row.constructUnitId)){
								guid = row.buildGuid;
							}else if(!$.common.isEmpty(row.buildGuid) && $.common.isEmpty(row.constructUnitId)){
								guid = row.buildGuid;
							}else if($.common.isEmpty(row.buildGuid) && !$.common.isEmpty(row.constructUnitId)){
								guid = row.constructUnitId;
							}
							if(!$.common.isEmpty(row.buildName) && !$.common.isEmpty(value)){
								name = row.buildName;
							}else if(!$.common.isEmpty(row.buildName) && $.common.isEmpty(value)){
								name = row.buildName;
							}else if($.common.isEmpty(row.buildName) && !$.common.isEmpty(value)){
								name = value;
							}
							if(!$.common.isEmpty(name) && !$.common.isEmpty(guid)){
								actions.push('<a href="javascript:void(0)" onclick="$.operate.detailTabRewriteOne(\'' + name + '\',\''+ guid +'\')">'+name+'</a> ');
								return actions.join('');
							}
						}
                    },
					{
                        field: 'totalName',
                        title: '施工总包单位(新数据)',
						visible: false
                    },
					{
                        field: 'totalGuid',
                        title: '施工总包单位标识符(新数据)',
						visible: false
                    },
                    {
                        field: 'totalCompany',
                        title: '施工总包单位(老数据)',
						visible: false
                    },
					{
                        field: 'totalCompanyGuid',
                        title: '施工总包单位标识符(老数据)',
						visible: false
                    },
					{
                        field: 'totalCompanyName',
                        title: '施工总包单位',
						formatter: function (value, row, index) {
							var actions = [];
							var name = '';
							var guid = '';
							if(!$.common.isEmpty(row.totalGuid) && !$.common.isEmpty(row.totalCompanyGuid)){
								guid = row.totalGuid;
							}else if(!$.common.isEmpty(row.totalGuid) && $.common.isEmpty(row.totalCompanyGuid)){
								guid = row.totalGuid;
							}else if($.common.isEmpty(row.totalGuid) && !$.common.isEmpty(row.totalCompanyGuid)){
								guid = row.totalCompanyGuid;
							}
							if(!$.common.isEmpty(row.totalName) && !$.common.isEmpty(value)){
								name = row.totalName;
							}else if(!$.common.isEmpty(row.totalName) && $.common.isEmpty(value)){
								name = row.totalName;
							}else if($.common.isEmpty(row.totalName) && !$.common.isEmpty(value)){
								name = value;
							}
							if(!$.common.isEmpty(guid) && !$.common.isEmpty(name)){
								actions.push('<a href="javascript:void(0)" onclick="$.operate.detailTabRewriteTwo(\'' + name + '\',\''+ guid +'\')">'+name+'</a> ');
								return actions.join('');
							}
						}
                    },
                    {
                        field: 'compactPrice',
                        title: '合同金额'
                    },
                    {
                        field: 'developmentScope',
                        title: '建设规模'
                    },
                    {
                        field: 'state',
                        title: '状态'
	                },
                    {
                        field: 'reportTime',
                        title: '监督时间',
						formatter: function (value, row, index) {
							if(value == '' || value == null){
								return value;
							}else{
								return moment(value).format('YYYY-MM-DD');	
							}
						}
	                },
					{
	                    field: 'opera',
	                    title: '功能区',
                        formatter: function (value, row, index) {
                            var actions = [];
                            actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="$.operate.editTabRewrite(\'' + row.unitEngineeringName + '施工许可申请\',\'' + row.cpGuid + '\')"><i class="fa fa-edit"></i>申请表</a> ');
                            return actions.join('');
	                       }
	                }]
        };
    	$.table.init(options);
    });
    </script>
</body>
</html>